package cn.ac.iscas.domain.response.middleplatform;

import java.io.Serializable;

/**
 * @author zhuquanwen
 * @date 2017/12/25 16:41
 **/
public class ResponseEntity<T> implements Serializable {

    /**
     * http状态码
     */
    protected Integer status = 200;
    /**
     * 给予用户提示的信息
     */
    protected String message;

    /**
     * 出现错误的详细描述(调试)
     */
    protected String desc;

    /**
     * 异常堆栈信息
     */
    protected String stackTrace;

    /**
     * 返回值
     */
    protected T data;

    /**
     * 访问URL
     */
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    protected String requestURL;

    /**
     * 当前接口访问耗时
     */
    protected long tookInMillis;

    /**
     * 过时的参数，未来会删除
     */
    @Deprecated
    protected int total;

    public ResponseEntity(Integer status, String message) {
        super();
        this.status = status;
        this.message = message;
    }

    public ResponseEntity() {
        super();
        this.message = "操作成功";
    }

    public ResponseEntity(String message) {
        super();
        this.message = message;
    }

    public static ResponseEntity success(Object data) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.message = "操作成功";
        responseEntity.data = data;
        return responseEntity;
    }

    public static ResponseEntity failure(Integer status, String message) {
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.message = message;
        responseEntity.status = status;
        return responseEntity;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getStackTrace() {
        return stackTrace;
    }

    public void setStackTrace(String stackTrace) {
        this.stackTrace = stackTrace;
    }

    public T getValue() {
        return data;
    }

    public void setValue(T data) {
        this.data = data;
    }

    public String getRequestURL() {
        return requestURL;
    }

    public void setRequestURL(String requestURL) {
        this.requestURL = requestURL;
    }

    public long getTookInMillis() {
        return tookInMillis;
    }

    public void setTookInMillis(long tookInMillis) {
        this.tookInMillis = tookInMillis;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
